varying vec4 vmPosition;
varying vec2 vUv;
uniform float uMinHeight;
uniform float uMaxHeight;
uniform float uTime;
varying vec3 vNormal;
uniform vec3 uDirectionalColor;
uniform vec3 uDirection;
void main() {
	vec3 c1 = vec3(1.0, 1.0, 0.0);
  vec3 c2 = vec3(1.0, 0.0, 0.0);
	vec3 c3 = vec3(0.0,0.4,0.9);
  vec3 c=mix(c1,c2,smoothstep(0.0,uMaxHeight,vmPosition.z));
	float weight = max(dot(normalize(vNormal), normalize(uDirection)), 0.0);
  gl_FragColor = vec4(c*weight, 1.0);

	float d=distance(vmPosition.xy,vec2(0.0,0.0));
	float d1=uTime*4.0,d2=uTime*4.0+200.0;
	if(d<d2&&d>d1){
		float dd=smoothstep(d1,d2,d);
		vec3 cc=mix(c,c3,dd);
		gl_FragColor=vec4(cc*weight, 0.9);
	}

	if(d<d2-500.0&&d>d1-500.0){
		float dd=smoothstep(d1-500.0,d2-500.0,d);
		vec3 cc=mix(c,c3,dd);
		gl_FragColor=vec4(cc*weight, 0.8);
	}

	if(d<d2-1000.0&&d>d1-1000.0){
		float dd=smoothstep(d1-1000.0,d2-1000.0,d);
		vec3 cc=mix(c,c3,dd);
		gl_FragColor=vec4(cc*weight, 0.6);
	}

	if(vmPosition.z>uTime&&vmPosition.z<5.0+uTime){
		vec3 cc=mix(c2,c1,smoothstep(0.0,uMaxHeight,vmPosition.z));
		gl_FragColor=vec4(cc*(1.0-weight), 1.0);
	}
}